import Vue from 'vue'
import Router from 'vue-router'
import HelloWorld from '@/components/HelloWorld'
import Dad from "@/pages/Dad"// 引入组件
import Home from "@/pages/Home"
import Lists from "@/pages/Lists"
import News from "@/pages/News"
import Car from "@/pages/Car"
import My from "@/pages/My"
const mypush=Router.prototype.push
Router.prototype.push=function(v){
  return mypush.call(this,v).catch(e=>e)
}
Vue.use(Router)// 注册路由

export default new Router({
  // 路径模板 路由组件
  routes: [// 所有路由组件的集合
    {
      path: '/car',
      name: 'car',
      component: Car
    },
    {
      path:"/dad",// 声明组件对应的路径 通过此路径访问对应的组件
      name:"dad",// 此路由组件的名称
      component:Dad// 注册组件
    },// 在路由中注册组件
    {
      path:"/",
      name:"home",
      component:Home,
      children:[
        {
          path:"news",// 二级路由不加 /
          name:"news",
          component:News
        },
        {
          path:"lists",
          name:"lists",
          component:Lists
        }
      ]
    },
    {
      path:"/my",
      name:"my",
      component:My
    }
  ]
})
